package com.hrzyit.whistle.cases.ui.activity

import android.os.Bundle
import kotlinx.android.synthetic.main.activity_case_time_line.*
import com.hrzyit.whistle.cases.R
import android.support.v7.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.hrzyit.base.ui.activity.BaseMvpActivity
import com.hrzyit.whistle.cases.data.bean.CaseInfoProcessVo
import com.hrzyit.whistle.cases.injection.component.DaggerCaseCenterComponent
import com.hrzyit.whistle.cases.injection.module.CaseCenterModule
import com.hrzyit.whistle.cases.presenter.CaseTimeLinePresenter
import com.hrzyit.whistle.cases.presenter.view.CaseTimeLineView
import com.hrzyit.whistle.cases.ui.adapter.CaseTimeLineAdapter


/**
 * 案件进度界面
 */
class CaseTimeLineActivity : BaseMvpActivity<CaseTimeLinePresenter>() , CaseTimeLineView {

    private lateinit var caseTimeLineAdapter:CaseTimeLineAdapter

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_case_time_line)

        initView()

        initData()
    }

    /**
     * 初始化界面
     */
    private fun initView() {
        val layoutManager = LinearLayoutManager(this)
        layoutManager.orientation = LinearLayoutManager.VERTICAL

        mTimeLineRecyclerView.layoutManager = layoutManager

//        val mItemDecoration = ItemDecoration(this,100)
        // mItemDecoration = DotItemDecoration.Builder(this)
//            .setOrientation(DotItemDecoration.VERTICAL)//如果LayoutManager设置了横向，那么这里也要设置成横向
////            .setItemStyle(DotItemDecoration.STYLE_DRAW)//选择dot使用图片资源或者用canvas画
//            .setTopDistance(20f)//单位dp
//            .setItemInterVal(10f)//单位dp
////            .setItemPaddingLeft(10f)//如果不设置，默认和item间距一样
////            .setItemPaddingRight(10f)//如果不设置，默认和item间距一样
//            .setDotColor(Color.RED)
//            .setDotRadius(2)//单位dp
//            .setDotPaddingTop(0)
//            .setDotInItemOrientationCenter(true)//设置dot居中
//            .setLineColor(Color.BLUE)//设置线的颜色
//            .setLineWidth(1f)//单位dp
//            .setEndText("END")//设置结束的文字
//            .setTextColor(Color.BLACK)
//            .setTextSize(10f)//单位sp
//            .setDotPaddingText(2f)//单位dp.设置最后一个点和文字之间的距离
//            .setBottomDistance(40f)//设置底部距离，可以延长底部线的长度
//            .create()

//        mTimeLineRecyclerView.addItemDecoration(mItemDecoration)

        caseTimeLineAdapter = CaseTimeLineAdapter(this)

        mTimeLineRecyclerView.adapter = caseTimeLineAdapter
    }

    private fun initData(){

        val caseId = intent.getLongExtra("caseId",0L)

        mPresenter.getCaseInfoProcessListByCaseId(caseId)
    }

    /**
     * Dagger2  注入
     */
    override fun injectComponent() {
        DaggerCaseCenterComponent.builder()
            .activityComponent(mActivityComponent)
            .caseCenterModule(CaseCenterModule())
            .build()
            .inject(this)

        mPresenter.mView = this
    }

    override fun onGetCaseInfoProcessListByCaseIdSuccess(result: MutableList<CaseInfoProcessVo>) {
        caseTimeLineAdapter.setData(result)
    }
}
